package com.oauth.google.server.conf;

import java.util.EnumSet;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import com.oauth.google.server.global.GmailGlobalService;
import com.oauth.service.application.registry.beans.ApplicationInfoBean;
import com.oauth.service.global.ApplicationGlobalService;
import com.oauth.service.global.beans.GlobalDataType;

/**
 * Uncomment @Qualifer annotation to enable gmail app.
 * 
 * @author asanthan
 * 
 */
@Configuration
// @Qualifier("applicationInfoBean")
public class GmailInfoBean implements ApplicationInfoBean {

	@Value("${gmail.key}")
	private Long mKey;

	@Value("${gmail.name}")
	private String mName;

	@Value("${gmail.addUrl}")
	private String mAddUrl;

	@Value("${gmail.iconImageUrl}")
	private String mIconUrl;

	@Value("${gmail.appImageUrl}")
	private String mImageUrl;

	@Value("${gmail.global.datatypes}")
	private String globalDataTypes;

	/**
	 * Inject global service once it supports global data types.
	 */
	@Autowired
	private GmailGlobalService mAppGlobalService;

	@Override
	public String getAddUrl() {
		return mAddUrl;
	}

	@Override
	public ApplicationGlobalService getAppGlobalService() {
		return mAppGlobalService;
	}

	@Override
	public String getIconUrl() {
		return mIconUrl;
	}

	@Override
	public String getImageUrl() {
		return mImageUrl;
	}

	@Override
	public Long getKey() {
		return mKey;
	}

	@Override
	public String getName() {
		return mName;
	}

	@Override
	public EnumSet<GlobalDataType> getGlobalDataType() {
		return globalDataTypes == null ? null : GlobalDataType.getEnumSetByName(globalDataTypes);
	}

}
